/** @jsxImportSource @emotion/react */
import * as React from "react";
import {Text, useTheme,} from "customize-easy-ui-component";
import {ReportViewProps,} from "../../common/base";
import {末尾链接, 落款单位地址,} from "../../common/rarelyVary";
import {检验结论报告, } from "./viewRes";
import {useSubRepMain} from "../../hook/useSubRepMain";
import {useRepMenuDirItems} from "../../hook/useMainRepUrlOr";
import {首页设备概况Dzgl, } from "./rarelyVary";
import {VsProjects默认} from "./editor";
import {useItemsMapPressure} from "../../common/pressure";
import {注意事项MVS, 目录页VS} from "../../movable/rarelyVary";
import {ReportFirstPageHeadNmaNmbm, } from "../../contain/rarelyVary";
import {缺陷问题处理} from "./viewDefect";
import {锅炉简图View} from "./viewSimpic";
import {PressureComponentsVw,} from "./viewPresCm";
import {MaterialReviewVw} from "./MaterialReview";
import {MacroscopicVw} from "./Macroscopic";
import {PipeLineDiagram} from "../viewLineDg";
import {DrawingsExplanVw} from "./DrawingsExplan";
import {LargeSlabBeamVw} from "./LargeSlabBeam";
import {DimensionInspVw} from "./DimensionInsp";
import {CutPipeScaleVw} from "./CutPipeScale";

//原版多出的”附页.pdf“没纳入 ；  "强度校核报告.pdf"也自带的。
export const ReportView: React.FunctionComponent<ReportViewProps> = ({
    repId,   source: orc,  verId,rep,
}) => {
    const theme= useTheme();
    const [mapFxian]=useItemsMapPressure({ projects:orc.Projects });
    const [rootMenu]=useRepMenuDirItems(VsProjects默认, orc.Projects, `/reportView/${rep?.modeltype}/ver/${verId}/${repId}`);
    const [renderThickm]= useSubRepMain("cm/thickm", {nestMd:'THICK_MS',orc, repId:repId!, rep, NestMbVer:1});
    //? 强度校核报告  是通用的吗？
    const [renderRadioTs ]= useSubRepMain("cm/radio", {nestMd:'RADIO_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderUtrSonic]= useSubRepMain("cm/sonic", {nestMd:'SONIC_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [renderTofd]= useSubRepMain("cm/tofd", {nestMd:'TOFD_TS', orc, repId:repId!, rep, NestMbVer:1});
    const [magnetic ]= useSubRepMain("cm/magnetic", {nestMd:'MAGNT_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [permeation ]= useSubRepMain("cm/permeation", {nestMd:'PERME_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [hardness ]= useSubRepMain("cm/hardness", {nestMd:'HARD_TS',orc, repId:repId!, rep, NestMbVer:1});
    const [swelling ]= useSubRepMain("cm/swelling", {nestMd:'SWELLING_MS',orc, repId:repId!, rep, NestMbVer:1});
    const [strength_vfb ]= useSubRepMain("boiler/strength_vfb", {nestMd:'STRENGTH_VFB',orc, repId:repId!, rep, NestMbVer:1});
    const [pipe_creep ]= useSubRepMain("boiler/pipe_creep", {nestMd:'PIPE_CREEP',orc, repId:repId!, rep, NestMbVer:1});
    const [out_roundness ]= useSubRepMain("boiler/out_roundness", {nestMd:'OUT_ROUNDNESS',orc, repId:repId!, rep, NestMbVer:1});
    const [oxideskin_ac ]= useSubRepMain("boiler/oxideskin_ac", {nestMd:'OXIDESKIN_AC',orc, repId:repId!, rep, NestMbVer:1});
    const [oxideskin_thick ]= useSubRepMain("boiler/oxideskin_thick", {nestMd:'OXIDESKIN_THICK',orc, repId:repId!, rep, NestMbVer:1});
    const [endoscopic_ex ]= useSubRepMain("boiler/endoscopic_ex", {nestMd:'ENDOSCOPIC_EX',orc, repId:repId!, rep, NestMbVer:1});

   return (
    <React.Fragment>
        {rootMenu}
        <div css={{"@media not print": {marginTop: '1rem', marginBottom: '1rem'}}}>
            <div css={{
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'space-between',
                "@media print": {height: '100vh', pageBreakInside: 'avoid',}
            }}>
                {ReportFirstPageHeadNmaNmbm({theme, rep, mbbm: 'FJB/TM-1007-1-0-2022'})}
                <div>
                    <Text variant="h3" css={{
                        textAlign: 'center',
                        "@media (min-width:690px),print and (min-width:538px)": {
                            fontSize: theme.fontSizes[6],
                        }
                    }}>
                        电站锅炉内部检验报告
                    </Text>
                    <br css={{"@media not print": {display: 'none'}}}/>
                    <Text variant="h5" css={{
                        textAlign: 'center',
                    }}> （ FJB/GC-1003-0-2021 ）
                    </Text>
                </div>
                <div>
                    {首页设备概况Dzgl({theme, orc, rep})}
                </div>
                <div css={{textAlign: 'center', "@media print": {pageBreakInside: 'avoid'}}}>
                    {落款单位地址}
                </div>
            </div>
            {注意事项MVS({
                rep,
                comply: '书为依据《锅炉安全技术规程》(TSG 11-2020)制定，适用于电站锅炉内部检验报告的结论报告，检验结论仅代表该设备在检验时的安全状况'
            })}

            {目录页VS({theme, orc, rep, suffix: true})}
            {检验结论报告({theme, orc, rep})}
            {缺陷问题处理({theme, orc, rep})}
            {mapFxian.get('锅炉简图')?.do && 锅炉简图View({theme, orc, rep})}
            {/*因为前面加了逻辑&&条件所以不能直接用#hook报错哦 {mapFxian.get('主要受压元件情况')?.do &&  主要受压元件({theme, orc, rep}) }*/}
            {mapFxian.get('主要受压元件情况')?.do && <PressureComponentsVw orc={orc} rep={rep}/>}

            {mapFxian.get('资料查阅')?.do && <MaterialReviewVw orc={orc} rep={rep}/>}
            {mapFxian.get('宏观检查')?.do && <MacroscopicVw orc={orc} rep={rep}/>}
            {/*{宏观检验报告({theme, orc, rep})}*/}

            {mapFxian.get('部件示意图')?.do &&
                <PipeLineDiagram orc={orc} rep={rep} title={'部件示意图'}/>
            }
            {/*原办法不支持多个子报告{mapFxian.get('内窥镜检查')?.do && <EndoscopicVw orc={orc} rep={rep}/>}*/}
            {mapFxian.get('内窥镜检查')?.do && endoscopic_ex}

            {mapFxian.get('胀粗测量')?.do && swelling}
            {mapFxian.get('壁厚测定')?.do && renderThickm}
            {mapFxian.get('磁粉检测')?.do && magnetic}
            {mapFxian.get('渗透检测')?.do && permeation}
            {mapFxian.get('射线检测')?.do && renderRadioTs}
            {mapFxian.get('超声检测')?.do && renderUtrSonic}
            {mapFxian.get('TOFD检测')?.do && renderTofd}
            {mapFxian.get('相控阵检测')?.do && <h2>没找到模板啊</h2>}
            {mapFxian.get('硬度检测')?.do && hardness}
            {mapFxian.get('金相分析')?.do && <h2>模板还未做的分项</h2>}
            {mapFxian.get('大板梁挠度检查')?.do && <LargeSlabBeamVw orc={orc} rep={rep}/>}

            {mapFxian.get('尺寸检查')?.do && <DimensionInspVw orc={orc} rep={rep} table='尺寸表' title={'尺寸检查报告'}/>}
            {mapFxian.get('割管垢样检验')?.do && <CutPipeScaleVw orc={orc} rep={rep} table='割管表' title={'割管垢样检验报告'}/>}

            {mapFxian.get('强度校核')?.do && strength_vfb}
            {mapFxian.get('管道监督段蠕变测量')?.do && pipe_creep}
            {mapFxian.get('弯管不圆度测量')?.do && out_roundness}
            {mapFxian.get('氧化皮堆积量测量')?.do && oxideskin_ac}
            {mapFxian.get('管壁氧化皮厚度测量')?.do && oxideskin_thick}

            {mapFxian.get('其它')?.do && <h2>没有模板的分项：其它</h2>}
            {mapFxian.get('联络单意见书回复检验偏离单')?.do && <DrawingsExplanVw orc={orc} rep={rep} table='联络单' reserve='6.5rem' title={'联络单意见书回复检验偏离单'}/>}
        </div>
        {末尾链接({template: rep?.modeltype, verId, repId: repId || ''})}
    </React.Fragment>
    );
}
